package jnpf.model.dify.data;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * 知识库的文档列表
 */

@Data
public class KnowledgeBase {

    @ApiModelProperty("唯一标识符")
    private String id;

    @ApiModelProperty("名称")
    private String name;

    @ApiModelProperty("描述，可为空")
    private String description;

    @ApiModelProperty("提供者")
    private String provider;

    @ApiModelProperty("权限范围")
    private String permission;

    @ApiModelProperty("数据源类型，可为空")
    private String data_source_type;

    @ApiModelProperty("索引方式，可为空")
    private String indexing_technique;

    @ApiModelProperty("关联应用数量")
    private int app_count;

    @ApiModelProperty("文档数量")
    private int document_count;

    @ApiModelProperty("单词数量")
    private int word_count;

    @ApiModelProperty("创建者唯一标识符")
    private String created_by;

    @ApiModelProperty("创建时间戳")
    private long created_at;

    @ApiModelProperty("更新者唯一标识符")
    private String updated_by;

    @ApiModelProperty("更新时间戳")
    private long updated_at;

    @ApiModelProperty("嵌入模型，可为空")
    private String embedding_model;

    @ApiModelProperty("嵌入模型提供者，可为空")
    private String embedding_model_provider;

    @ApiModelProperty("嵌入功能是否可用")
    private boolean embedding_available;

    @ApiModelProperty("检索模型字典相关信息")
    private RetrievalModelDict retrieval_model_dict;

    @ApiModelProperty("标签列表")
    private List<String> tags;

    @ApiModelProperty("外部知识信息相关")
    private ExternalKnowledgeInfo external_knowledge_info;

    @ApiModelProperty("外部检索模型相关信息")
    private ExternalRetrievalModel external_retrieval_model;

    @Data
    public static class RetrievalModelDict {
        @ApiModelProperty("搜索方法")
        private String search_method;

        @ApiModelProperty("是否启用重排序")
        private boolean reranking_enable;

        @ApiModelProperty("重排序模式，可为空")
        private String reranking_mode;

        @ApiModelProperty("重排序模型相关信息")
        private RerankingModel reranking_model;

        @ApiModelProperty("权重，可为空")
        private Map<String, Double> weights;

        @ApiModelProperty("返回结果数量上限")
        private int top_k;

        @ApiModelProperty("是否启用分数阈值，若启用则下面的分数阈值字段有效")
        private boolean score_threshold_enabled;

        @ApiModelProperty("分数阈值，若启用分数阈值功能则该字段有值，可为空")
        private Double score_threshold;

        @Data
        // 重排序模型内部类定义
        public static class RerankingModel {
            @ApiModelProperty("重排序提供者名称")
            private String reranking_provider_name;

            @ApiModelProperty("重排序模型名称")
            private String reranking_model_name;
        }

    }
    @Data
    public static class ExternalKnowledgeInfo {
        @ApiModelProperty("外部知识唯一标识符，可为空")
        private String external_knowledge_id;

        @ApiModelProperty("外部知识 API 唯一标识符，可为空")
        private String external_knowledge_api_id;

        @ApiModelProperty("外部知识 API 名称，可为空")
        private String external_knowledge_api_name;

        @ApiModelProperty("外部知识 API 端点，可为空")
        private String external_knowledge_api_endpoint;

    }

    @Data
    public static class ExternalRetrievalModel {
        @ApiModelProperty("返回结果数量上限")
        private int top_k;
        @ApiModelProperty("分数阈值")
        private double score_threshold;

    }

}
